// @before-stub-for-debug-begin
#include <vector>
#include <string>
#include "commoncppproblem48.h"

using namespace std;
// @before-stub-for-debug-end

/*
 * @lc app=leetcode.cn id=48 lang=cpp
 *
 * [48] 旋转图像
 */

// @lc code=start
class Solution {
public:
        /**
         * @brief: 两次矩阵转换进行求解
         * @param[in] {*}
         * @param[out] {*}
         * @return {*}
         * @note: 
         */
        void rotate(vector<vector<int>>& matrix) {
            int temp;
            int n = matrix.size() - 1;
            if(n == 0)
            {
                return ;
            }
            int m = n;
            //先按照左上->右下对角线进行互换元素
            for(int i = 0; i < n ; i++)
            {
                for(int j = 0; j < m; j++)
                {
                    temp = matrix[i][j];
                    matrix[i][j] = matrix[n-j][n-i];
                    matrix[n-j][n-i] = temp;
                }
                m--;
            }

            // 再按照中对称线互换
            for(int i = 0 ; i <= n/2;i++)
            {
                for(int j = 0; j <= n ;j++)
                {
                    temp = matrix[i][j];
                    int temp2 = matrix[n-i][j];
                    matrix[i][j] = matrix[n-i][j];
                    matrix[n-i][j] = temp;
                }
            }
            return;

        }
    


};
// @lc code=end

